#!/bin/ksh
TZ=TZ+24
RmanLOG=/home/oracle/scripts/rmanlog_`date +%Y%m%d`.log

if [ -f $RmanLOG ]
then
  cat $RmanLOG | grep -v "archive log filename" >/tmp/rmanbackup.log
  TEST1=`grep -c "Recovery Manager complete" /tmp/rmanbackup.log`
  LineEnd=`sed -n '/Finished backup/=' /tmp/rmanbackup.log`
  set -A LineNum `echo ${LineEnd}`
  CT=${#LineNum[*]}
  ((CT=CT-1))
  sed -n "1,${LineNum[$CT]}p" /tmp/rmanbackup.log >/tmp/rman.log
  tail -n3 /tmp/rmanbackup.log >>/tmp/rman.log
  if [ $TEST1 -gt 0 ]
  then
    TEST2=`grep -c "RMAN-" /tmp/rmanbackup.log`
    if [ $TEST2 -gt 0 ]
    then
      echo "					"
      echo "*****  Rman Maybe Have Error *******"
      echo "                                    "
      echo "***** Some Detail As Following ******"
      cat /tmp/rmanbackup.log | more
    else
      echo "                                         "
      echo "**** Rman Have Finish Sucessfully *******"
      echo "                                         " 
      echo "     Some Detail As Following ******"
      cat /tmp/rman.log |more 
    fi 
  else
   echo "                                      "
   echo "******* Rman Maybe Runing Now ********"
   echo "				       "
   echo "*****  Some Detail As Following ******"
   cat /tmp/rmanbackup.log | more
  fi
else
  echo "                                      "
  echo " ******* Rman Script Not Run *********"
  echo " *** Or Rman Log had deleted By SA ***" 
fi
